package com.llgz.hotelmanageapi.controller;

import com.llgz.hotelmanageapi.common.CommonResult;
import com.llgz.hotelmanageapi.pojo.DTO.LoginDTO;
import com.llgz.hotelmanageapi.service.impl.CommonServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Bernie_fang
 * @Description:
 * @create 2021/7/23 15:38
 **/
@RestController
@RequestMapping("/common")
public class CommonController {

    @Autowired
    private CommonServiceImpl commonService;

    @PostMapping("/login")
    @ApiOperation(value = "登录", response = CommonResult.class, httpMethod = "POST")
    public CommonResult addCommodityInfo(@RequestBody LoginDTO loginDTO){
        return commonService.login(loginDTO);
    }

    @GetMapping("/test")
    @RequiresRoles(value = {"root","admin"}, logical = Logical.OR)
    @ApiOperation(value = "测试", response = CommonResult.class, httpMethod = "POST")
    public CommonResult test(){
        return CommonResult.successResponse("成功！");
    }

}
